package com.cheer.dao;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cheer.entity.MallCreditRecordEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 积分记录表
 *
 * @author cheer
 */
@Mapper
@Repository
public interface MallCreditRecordDao extends BaseMapper<MallCreditRecordEntity> {

    default List<MallCreditRecordEntity> selectListByUserIdLimit(int start, int offset, Integer userId) {
        return selectList(new QueryWrapper<MallCreditRecordEntity>()
                .eq("user_id", userId)
                .orderByDesc("create_time")
                .last("limit " + start + "," + offset));
    }
}
